<template>
  <div>
    <div class="background">
      <div class="btnbg">
        <ul>
          <li class="inputStyle">
            <p>账号:</p>
            <input type="text" v-model='phone' autocomplete="off" @focus="xianshi">
          </li>
          <li class="tishi">{{yzUser}}</li>
          <li class="inputStyle">
            <p>密码:</p>
            <input type="password" v-model='password' autocomplete="new-password" @focus="xianshi">
          </li>
          <li class="tishi2">{{mima}}</li>
        </ul>
        <ul>
          <li class='resiger' style='cursor:pointer'>
            <span @click='$router.push({path:"/forget"})'>忘记密码</span>
            <span @click='$router.push({path:"/register"})'>点击注册</span>
          </li>
        </ul>
        <!-- <div class='resiger' style='cursor:pointer'>
          <span @click='$router.push({path:"/forget"})'>忘记密码</span>
          <span @click='$router.push({path:"/register"})'>点击注册</span>
        </div> -->
        <div class="login">
          <p @click='login'>登录</p>
        </div>
        <div class="loginStyle">
          {{loginIf}}
        </div>
      </div>
      <div class="instructions">
        <h4>游戏简介说明:</h4>
        <p>布勒游戏为布勒旗下一款区块链游戏，游戏内容为布勒挖参和布勒炼丹两种。</p>
      </div>
    </div>
    <!-- <div class='back'>
      <span @click='back'>&lt; 返回</span>
    </div> -->
  </div>
</template>

<script>
import $ from "jquery";
export default {
  data() {
    return {
      phone: "",
      password: "",
      yzUser: "",
      mima: "",
      loginIf: "",
    };
  },
  created() {
    // u.usreALL(data=>{
    //   console.log(data)
    // })
  },
  mounted() {
    this.$parent.flag1 = false;
    this.$parent.flag2 = false;
  },
  methods: {
    xianshi() {
      this.yzUser = ''
      this.mima = ''
      this.loginIf = ''
    },
    back() {
      history.back();
    },
    login() {
      var that = this;
      u.login({ username: this.phone, password: this.password }, data => {
        if (data[0].code == 200) {
          u.setStore("user", {
            name: this.phone,
            userid: this.phone,
            password: this.password
          });
          u.setStore("userInfo", data[0].user);

          that.$router.push({ path: "/choosePage" });
          let data1 = data;
          //所有的汇率
          u.exchangeRate(data => {
            // let exchange = data[0].winning;
            // localStorage.setItem("exchange",JSON.stringify(exchange));//汇率存储
            // console.log(JSON.parse(localStorage.getItem("exchange")));
            // u.setStore("winning", data[0].winning);
            //所有金银铜种子
            u.setStore(
              "mount",
              data1[0].user.seeds_amount * data[0].winning.gold +
                data1[0].user.silver_seeds_amount * data[0].winning.silver +
                data1[0].user.copper_seeds_amount * data[0].winning.copper
            );
          });
        } else if (data[0].code == 404) {
          this.yzUser = "该账号不存在"
        } else if (data[0].code == 500) {
          this.mima = "密码错误"
        }else if (this.phone=='') {
          this.yzUser = "请输入用户名"
        }else if (this.password=='') {
          this.mima = "请输入密码"
        }else {
          // this.$parent.loading({
          //   message: "登录失败",
          //   type: false
          // });
          this.loginIf = "登录失败"
        }
      });
    }
  }
};
</script>

<style lang='less' scoped>
.resiger {
  display: flex;
  justify-content: space-between;
  padding-right: 50px;
  padding-left: 30px;
  height: 30px;
  line-height: 30px;
  // position: relative;
  // top: -30px;
}
.background {
  width: 100vw;
  height: 100vh;
  background: url("../../static/image/ginsengbg.png") no-repeat;
  background-size: 100% 100%;
  position: relative;
  .btnbg {
    padding-top: 20px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 55%;
    height: 24%;
    background: url("../../static/image/assetsbg1.png") no-repeat;
    background-size: 100% 100%;
    ul {
      padding: 6% 4% 0 4%;
      height: 130px;
      .inputStyle {
        display: flex;
        align-items: center;
        background: url("../../static/image/btnLong.png") no-repeat;
        background-size:cover;
        height: 45%;
        padding-left: 20px;
        color: #ffffff;
        background-size: 100% 100%;
        font-size: 16px;
        input {
          z-index: 99;
          background-color: transparent;
          line-height: normal;
          outline: 0;
          border: none;
          color: #ffffff;
          margin: 5px 0 0 25px;
          text-shadow: 0 3px #a56a2c, -3px 0 #a56a2c, -3px 1px #a56a2c, -3px 1px #a56a2c;
        }
        p {
          text-shadow: 0 2px #3a230a, 2px 0 #3a230a, -2px 0 #3a230a,
            0 -2px #3a230a;
        }
      }
    }
    .login {
      width: 40%;
      height: 62px;
      background: url("../../static/image/btnYellow.png") no-repeat;
      position: absolute;
      left: 50%;
      top:80%;
      transform: translate(-50%, -50%);
      background-size: 100%;
      p {
        text-align: center;
        line-height: 58px;
        font-size: 18px;
        letter-spacing: 8px;
        color: #ffffff;
        text-shadow: 0 1.5px #a65d09, 1px 0 #a65d09, -1px 0 #a65d09,
          0 -1px #a65d09;
      }
    }
  }
  .instructions{
    position: absolute;
    left: 23%;
    top: 63%;
    color: #805200;
    h4{
      font-size: 18px;
      line-height: 42px;
    }
    p{
      font-size: 16px;
    }
  }
}
.back {
  width: 14%;
  height: 47px;
  background: url("../../static/image/back_1.png") no-repeat;
  position: absolute;
  background-size: 100%;
  top: 5%;
  left: 70%;
  span {
    display: block;
    text-align: center;
    color: #ffffff;
    font-size: 16px;
    line-height: 41px;
    text-shadow: 0 1.5px #a65d09, 1px 0 #a65d09, -1px 0 #a65d09, 0 -1px #a65d09;
  }
}
.tishi{
  height: 40px;
  line-height: 30px;
  padding-left: 5px;
  color: #ffffff;
  font-weight: bold;
  text-align:center;
  text-shadow: 0 1.5px red, 1px 0 red, -1px 0 red, 0 -1px red;
}
.tishi2{
  height: 50px;
  line-height: 65px;
  padding-left: 5px;
  color: #ffffff;
  font-weight: bold;
  text-align:center;
  text-shadow: 0 2px red, 2px 0 red, -2px 0 red, 0 -2px red;
}
.loginStyle{
  text-align: center;
  margin-top: 10px;
  color: #ffffff;
  font-size: 15px;
  text-shadow: 0 2px red, 2px 0 red, -2px 0 red, 0 -2px red;
}
</style>
